home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The CICA Windows Explosion!
/
The CICA Windows Explosion! - Disc 2.iso
/
pdoxwin
/
pi0994.zip
/
JM0994.EXE
/
TRACUTIL.SC
next >
Wrap
Text File
|
1994-06-02
|
19KB
|
514 lines
;************************************************************************
; The following Utility Library of procedures are:
;
; Copyrighted (c) 1992-94 Micro-Phyla Systems All Rights Reserved
; Author: John B. Moore
; 5256 South Mission Rd. Suite #110
; Bonsall Calif. 92003
; (619) 631-3085
;
; This code is available as supplimental procedures for the TracTuner
; Utilities and as samples for educational purposes. Using these procedures
; outside the scope of these utilities is the sole reponsibility of the
; user.
;**************************************************************************
; ============================================================
; 10-05-92
; Creates a variable length message window in the lower
; center of the workspace, single line. Cannot exceed 65 characters
; A null string "" cancels window
; The string "work" places the window with "Working...!" in it.
; ------------------------------------------------------------
PROC QuickMsg_u(msg_a)
PRIVATE Procname.a,
current_h,
width_n,
origincol_n
Procname.a = "QuickMsg_u"
;---check for null string to cancel window if it exists
IF msg_a = "" AND
ISASSIGNED(g_handle_bag["QUICK"]) THEN
ChiseledBoxDestructor_l("QUICK")
RETURN
ENDIF
IF msg_a = "" AND
NOT ISASSIGNED(g_handle_bag["QUICK"]) THEN
RETURN
ENDIF
;--check and see if window already exists, if so clear IT
IF ISASSIGNED(g_handle_bag["QUICK"]) THEN
ChiseledBoxDestructor_l("QUICK")
ENDIF
;--first make sure string is not to large,
msg_a = SUBSTR(msg_a,1,65)
IF msg_a = "work" THEN
width_n = 12 + 4
ELSE
width_n = LEN(msg_a) + 13
wmsg_n = LEN(msg_a)
ENDIF
origincol_n = INT((80 - width_n)/2)
;--create window
ChiseledBoxMaker_u(19,origincol_n,width_n,3,
32,47,"QUICK")
;--write text to box
IF msg_a = "work" THEN
STYLE ATTRIBUTE 46
@ 1,2 ?? "Working"
STYLE ATTRIBUTE 164
@ 1,9 ?? "....!"
STYLE
ELSE
STYLE ATTRIBUTE 32
@ 1,2 ?? msg_a
STYLE ATTRIBUTE 164
@ 1,wmsg_n + 2 ?? "....!"
STYLE
ENDIF
ENDPROC
;("QuickMsg_u")
; ============================================================
; 10-05-92
; Creates a window with chisled box double border
; Also creates a global handle in g_handle_bag Dynarray with
; index specified with var index_a
; ------------------------------------------------------------
PROC ChiseledBoxMaker_u(row_n,col_n,width_n,height_n,color_n,hilite_n,index_a)
PRIVATE Procname.a,
current_h,
fcurrent_h
Procname.a = "ChiseledBoxMaker_u"
;----grab current table image cursor location
IF NIMAGES() > 0 THEN
IF ISFIELDVIEW() THEN
current_h = GetMemoWindowHandle_h()
fcurrent_h = 0
ELSE
WINDOW HANDLE IMAGE IMAGENO() TO current_h
WINDOW HANDLE FORM TO fcurrent_h
ENDIF
ENDIF
IF NOT ISASSIGNED(g_handle_bag) THEN
DYNARRAY g_handle_bag[]
ENDIF
;---create dynarray attributes to format the window canvas
DYNARRAY attrib_bag[]
attrib_bag["CANVASHEIGHT"] = height_n
attrib_bag["CANVASWIDTH"] = width_n
attrib_bag["CANCLOSE"] = false
attrib_bag["CANMAXIMIZE"] = false
attrib_bag["CANMOVE"] = false
attrib_bag["CANRESIZE"] = false
attrib_bag["ECHO"] = true
attrib_bag["HASFRAME"] = false
attrib_bag["STYLE"] = color_n
WINDOW CREATE FLOATING @ row_n ,col_n
HEIGHT height_n
WIDTH width_n
ATTRIBUTES attrib_bag TO g_handle_bag[index_a]
;---set canvas to canvas window
SETCANVAS g_handle_bag[index_a]
;--create chiseled frame in the canvas window
FRAME DOUBLE FROM 0,0 TO height_n-1, width_n - 1
PAINTCANVAS ATTRIBUTE hilite_n 0,0,height_n-1,0
PAINTCANVAS ATTRIBUTE hilite_n 0,0,0,width_n - 2
;--return cursor to original location
IF NIMAGES() > 0 THEN
IF fcurrent_h <> 0 THEN
WINDOW SELECT fcurrent_h
WINDOW SELECT fcurrent_h
ELSE
WINDOW SELECT current_h
WINDOW SELECT current_h
ENDIF
ENDIF
ENDPROC
;("ChiseledBoxMaker_u")
; ============================================================
; 10-05-92
; Closes box created by "ChiseledBoxMaker_u"
; Returns true if successful, false if window handle does not exist
; ------------------------------------------------------------
PROC ChiseledBoxDestructor_l(index_a)
PRIVATE Procname.a,
current_h
Procname.a = "ChiseledBoxDestructor_l"
IF ISASSIGNED(g_handle_bag[index_a]) AND
ISWINDOW(g_handle_bag[index_a]) THEN
WINDOW HANDLE CURRENT TO current_h
WINDOW SELECT g_handle_bag[index_a]
WINDOW CLOSE
IF ISWINDOW(current_h) THEN
WINDOW SELECT current_h
WINDOW SELECT current_h
ENDIF
RELEASE VARS g_handle_bag[index_a] , attrib_bag
SETCANVAS DEFAULT
RETURN true
ELSE
RETURN false
ENDIF
ENDPROC
;("ChiseledBoxDestructor_l")
; ============================================================
; 09-07-92
; General message utility
; -each "line" must be followed by a "/"
; ------------------------------------------------------------
PROC GeneralMessage_u(text_a)
PRIVATE Procname_a,
dialog_w,
lines_n,
maxline_n,
row_n,
column_n,
oldcolor_bag,
newcolor_bag,
oldcanvas_h
Procname.a = "GeneralMessage_u"
DYNARRAY message_bag[]
lines_n = 1
maxline_n = 0
WHILE MATCH(text_a,"../..",message_bag[STRVAL(lines_n)],text_a)
maxline_n = MAX(LEN(message_bag[STRVAL(lines_n)]),maxline_n)
lines_n = lines_n +1
ENDWHILE
IF lines_n = 0 THEN
maxline_n = LEN(text_a)
ENDIF
row_n = INT((23 -lines_n+4)/2)
column_n = INT((79-maxline_n+4)/2)
GETCOLORS TO oldcolor_bag
DYNARRAY newcolor_bag[]
newcolor_bag[1032] = 32
newcolor_bag[1031] = 32
newcolor_bag[1045] = 32
newcolor_bag[1036] = 32
newcolor_bag[1042] = 78
SETCOLORS FROM newcolor_bag
BEEP BEEP SLEEP 100 BEEP BEEP SLEEP 100 BEEP BEEP
SHOWDIALOG "Message"
PROC "InsertMessage_u" TRIGGER "OPEN"
@row_n,column_n HEIGHT lines_n + 4 WIDTH maxline_n +4
PUSHBUTTON @lines_n,INT((maxline_n/2)-6) WIDTH 12
"Continue"
OK
DEFAULT
VALUE true
TAG "continue"
TO okkey_l
ENDDIALOG
SETCOLORS FROM oldcolor_bag
SETCANVAS DEFAULT
ENDPROC
;("GeneralMessage_u")
; ============================================================
; 09-07-92
; A dialog proc for inserting message into GeneralMessage_u
; --the vars a,b,c,d are dummy place holders
; ------------------------------------------------------------
PROC InsertMessage_u(a,b,c,d)
PRIVATE Procname.a,
n
Procname.a = "InsertMessage_u"
WINDOW HANDLE DIALOG TO dialog_w
SETCANVAS dialog_w
FOR n FROM 1 TO lines_n - 1
@ n-1 ,1
?? FORMAT("W"+STRVAL(maxline_n)+",AC",message_bag[STRVAL(n)])
ENDFOR
PAINTCANVAS ATTRIBUTE 32 0,1,lines_n+1,maxline_n+1
ENDPROC
;("InsertMessage_u")
; ============================================================
; 11-02-92
; Restores canvas
; ------------------------------------------------------------
PROC RestoreCanvas_u(canvas_h)
PRIVATE Procname_a
Procname_a = "RestoreCanvas_u"
IF ISWINDOW(canvas_h) THEN
SETCANVAS canvas_h
ELSE
SETCANVAS DEFAULT
ENDIF
ENDPROC
;("RestoreCanvas_u")
; ============================================================
; 11-03-92
; Restores old window selection
; ------------------------------------------------------------
PROC RestoreWindow_l(window_h)
PRIVATE Procname_a,
default_h
Procname_a = "RestoreWindow_l"
IF ISWINDOW(window_h) THEN
WINDOW SELECT window_h
WINDOW SELECT window_h
RETURN true
ELSE
;--let's try and land on the first image if available
; as a default 'landing place"
WINDOW HANDLE IMAGE 1 TO default_h
IF ISWINDOW(default_h) THEN
WINDOW SELECT default_h
WINDOW SELECT default_h
ELSE
GeneralMessage_u("ERROR !! Warning the system has ecountered an /"+
"and error in restoring the current window handle./"+
"Make note of where in the program this occurred, /"+
"exit the program and restart. Anykey continues /")
RETURN FALSE
ENDIF
ENDIF
ENDPROC
;("RestoreWindow_l")
; ============================================================
; 11-10-92
; Saves the current window handle and returns that value
; ------------------------------------------------------------
PROC SaveWindowHandle_n()
PRIVATE Procname_a,
ihandle_h,
fhandle_h,
chandle_h
Procname_a = "SaveWindowHandle_n"
WINDOW HANDLE IMAGE IMAGENO() TO ihandle_h
WINDOW HANDLE FORM TO fhandle_h
WINDOW HANDLE CURRENT TO chandle_h
;-- the following logic is that if a form handle is there it is
; the one we want returned, next is a image handle,
; and lastly the current window
SWITCH
CASE fhandle_h <> 0 : RETURN fhandle_h
CASE ihandle_h <> 0 : RETURN ihandle_h
CASE chandle_h <> 0 : RETURN chandle_h
OTHERWISE:
GeneralMessage_u("ERROR, Expecting a window handle assignment/"+
"no windows present. Exit module and report/"+
"error message.. Anykey continues.. /")
RETURN 0
ENDSWITCH
ENDPROC
;("SaveWindowHandle_n")
; ============================================================
; 11-10-92
; Save the current workspace position
; ------------------------------------------------------------
PROC SaveWorspace_u()
PRIVATE Procname_a
Procname_a = "SaveWorspace_u"
sv_current_h = SaveWindowHandle_n()
sv_oldcanvas_h = GETCANVAS()
sv_cfield_a = FIELD()
sv_ctable_a = TABLE()
sv_mode_a = SYSMODE()
ENDPROC
;("SaveWorspace_u")
; ============================================================
; 11-10-92
; Restores workspace
; ------------------------------------------------------------
PROC RestoreWorkspace_u()
PRIVATE Procname_a
Procname_a = "RestoreWorkspace_u"
RestoreWindow_l(sv_current_h)
RestoreCanvas_u(sv_oldcanvas_h)
If sv_mode_a = "CoEdit" THEN
COEDITKEY
ENDIF
MOVETO sv_ctable_a
MOVETO FIELD sv_cfield_a
IF ISASSIGNED(g_edit_a) THEN
IF g_edit_a = "View" THEN
IMAGERIGHTS READONLY
ENDIF
ENDIF
;--release all vars associated with the saveworkspace procedures
RELEASE VARS sv_current_h, sv_oldcanvas_h, sv_mode_a,sv_cfield_a,sv_ctable_a
ENDPROC
;("RestoreWorkspace_u")
; ===========================================================================
; gets and lists the handles/titles/origin location/size of all current
; windows on the desktop and sends info to printer so as to not distrub
; the current environment, can be place within any procedure to print a
; running log of window positions and status for debugging purposes...
; The break_a var is used for times you want to insert this into your code
; and assign a value to the break_a var to indicate the location of this
; printout in the code. (use as a window status "break"point..)
; ---------------------------------------------------------------------------
PROC DebugWindowInfo_u(break_a)
PRIVATE Procname_a,
currentstuff,
N,
windowhandlelist_r,
X,
wininfo_bag,
printset_a
Procname_a = "DebugWindowInfo_u"
OPEN PRINTER
PRINT FORMAT("W80,AC","* * * CURRENT WORKSPACE STATUS PRINTOUT * * *"),"\n\n",
"BREAK POINT DISCRIPTION: ", break_a, "\n\n",
FORMAT("W80,AC",FILL("≡",60)),"\n\n"
DYNARRAY currentstuff[]
;--find current status of windows
;current window
currentstuff["CURRENT_WINDOW_HANDLE_GETWINDOW"] = GETWINDOW()
WINDOW HANDLE CURRENT TO currentstuff["CURRENT_WINDOW_HANDLE_CURRENT"]
WINDOW HANDLE FORM TO currentstuff["CURRENT_WINDOW_HANDLE_FORM"]
WINDOW HANDLE DIALOG TO currentstuff["CURRENT_WINDOW_HANDLE_DIALOG"]
;current image
WINDOW HANDLE IMAGE IMAGENO() TO currentstuff["CURRENT_IMAGE_HANDLE"]
;current canvas
currentstuff["CURRENT_CANVAS_HANDLE"] = GETCANVAS()
;current image number
currentstuff["CURRENT_IMAGE_NUMBER"] = IMAGENO()
;current image type
currentstuff["CURRENT_IMAGETYPE_WHERE_CURSOR_IS"] = IMAGETYPE()
;number of current images
currentstuff["CURRENT_NUMBER_OF_IMAGES"] = NIMAGES()
;---------print current status
PRINT FORMAT("W80,AC",">> Current positions <<"),"\n",
FORMAT("W80,AC",FILL("▀",25)),"\n"
FOREACH N IN currentstuff
PRINT SPACES(5),
FORMAT("W35,AL",N), " = ",
FORMAT("W20,AL",currentstuff[N]),"\n"
ENDFOREACH
;---------window analysis
PRINT FORMAT("W80,AC",">> Window Info in Z order, Highest first <<"),"\n",
FORMAT("W80,AC",FILL("▀",40)),"\n\n"
;number of current window handles
WINDOW LIST TO windowhandlelist_r
FOR X FROM 1 TO ARRAYSIZE(windowhandlelist_r)
WINDOW GETATTRIBUTES windowhandlelist_r[X] TO wininfo_bag
IF wininfo_bag["FLOATING"] THEN
PRINT FILL("*",5),
FORMAT("W15,AL","Window handle" ), " = ",
FORMAT("W10,AL",windowhandlelist_r[X]),
" THIS WINDOW IS ABOVE THE GLOBAL ECHO LAYER","\n"
ELSE
PRINT FILL(".",5),
FORMAT("W15,AL","Window handle" ), " = ",
FORMAT("W20,AL",windowhandlelist_r[X]),"\n"
ENDIF
FOREACH N IN wininfo_bag
printset_a = "CANVAS,ECHO,FLOATING,HASFRAME,MAXIMIZED,"+
"ORIGINCOL,ORIGINROW,TITLE,WIDTH,HEIGHT"
IF SEARCH(N,printset_a)>0 THEN
PRINT SPACES(10),
FORMAT("W20,AL",N), " = ",
FORMAT("W20,AL",wininfo_bag[N]),"\n"
ENDIF
ENDFOREACH
PRINT "\n\n"
ENDFOR
PRINT "\f"
CLOSE PRINTER
ENDPROC
;("DebugWindowInfo_u")
; ============================================================
; 10-21-92
; A spartan version of "DebugWindowInfo_u" for use in tractunner
; ------------------------------------------------------------
PROC DebugWin_u()
PRIVATE Procname_a,
currentstuff,
label_a,
wininfo_bag,
firstrow_a,
secondrow_a,
printset_a,
X,
N,
windowhandlelist_r
Procname_a = "DebugWin_u"
OPEN PRINTER
DYNARRAY currentstuff[]
;--find current status of windows
;current window
currentstuff["CURRENT_WINDOW_HANDLE_GETWINDOW"] = GETWINDOW()
WINDOW HANDLE CURRENT TO currentstuff["CURRENT_WINDOW_HANDLE_CURRENT"]
WINDOW HANDLE FORM TO currentstuff["CURRENT_WINDOW_HANDLE_FORM"]
WINDOW HANDLE DIALOG TO currentstuff["CURRENT_WINDOW_HANDLE_DIALOG"]
;current image
WINDOW HANDLE IMAGE IMAGENO() TO currentstuff["CURRENT_IMAGE_HANDLE"]
;current canvas
currentstuff["CURRENT_CANVAS_HANDLE"] = GETCANVAS()
;current image number
currentstuff["CURRENT_IMAGE_NUMBER"] = IMAGENO()
;current image type
currentstuff["CURRENT_IMAGETYPE_WHERE_CURSOR_IS"] = IMAGETYPE()
;number of current images
currentstuff["CURRENT_NUMBER_OF_IMAGES"] = NIMAGES()
;---------print current status
PRINT FORMAT("W80,AC",">> Current positions <<"),"\n",
FORMAT("W80,AC",FILL("▀",25)),"\n"
FOREACH N IN currentstuff
PRINT SPACES(5),
FORMAT("W35,AL",N), " = ",
FORMAT("W20,AL",currentstuff[N]),"\n"
ENDFOREACH
PRINT "\n\n"
;---------window analysis
PRINT FORMAT("W80,AC",">> Window Info in Z order, Highest first <<"),"\n",
FORMAT("W80,AC",FILL("▀",40)),"\n\n"
;number of current window handles
WINDOW LIST TO windowhandlelist_r
FOR X FROM 1 TO ARRAYSIZE(windowhandlelist_r)
WINDOW GETATTRIBUTES windowhandlelist_r[X] TO wininfo_bag
IF wininfo_bag["FLOATING"] THEN
PRINT FILL("█",2),
FORMAT("W15,AL","Window handle" ), "= ",
FORMAT("W5,AL",windowhandlelist_r[X])
ELSE
PRINT FILL(".",2),
FORMAT("W15,AL","Window handle" ), " = ",
FORMAT("W5,AL",windowhandlelist_r[X])
ENDIF
printset_a = "ORIGINCOL,ORIGINROW,TITLE"
;--reset print rows
firstrow_a = ""
secondrow_a = ""
FOREACH N IN wininfo_bag
IF SEARCH(N,printset_a)>0 THEN
SWITCH
CASE N = "ORIGINCOL": label_a = "COL"
firstrow_a = firstrow_a +
FORMAT("W4,AL",label_a)+ " = "+
FORMAT("W6,AL",wininfo_bag[N])
CASE N = "ORIGINROW": label_a = "ROW"
firstrow_a = firstrow_a +
FORMAT("W4,AL",label_a)+ " = "+
FORMAT("W6,AL",wininfo_bag[N])
CASE N = "TITLE": label_a = "TITLE"
secondrow_a = secondrow_a +
FORMAT("W6,AL",label_a)+ " = "+
FORMAT("W35,AL",wininfo_bag[N])
ENDSWITCH
ENDIF
ENDFOREACH
PRINT firstrow_a,"\n", SPACES(10),secondrow_a,"\n"
ENDFOR
PRINT "\f"
CLOSE PRINTER
ENDPROC
;("DebugWin_u")